package com.nus.servlets;

import com.nus.beans.User;
import com.nus.database.ProjectsDBManager;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: dell
 * Date: 9/26/12
 * Time: 10:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class LoadCreateUserDetailsUserDetails extends AbstractServlet{

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        doGet(request, response);
    }
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        Connection connecton = getUserDatabaseConnection(request);
        ProjectsDBManager projectsDBManager = new ProjectsDBManager(connecton);

        List<User> usersList = projectsDBManager.getUsersListForProjects();
        request.setAttribute("usersList", usersList);
        projectsDBManager.close();

        RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/create_project.jsp");
        requestDispatcher.forward(request, response);
    }
}
